# Serial joystick example
#
no_logfile           = true;
scenario_type        = trials;

response_matching    = simple_matching;
response_port_output = false; 
write_codes          = false;

active_buttons       = 0;

default_background_color = 0, 0, 0;
default_font             = "arial";
default_font_size        = 20;
default_text_color       = 235, 235, 235;

begin;

picture {
   text { caption = " "; font_size = 24; } warningText;
   x = 0; y = 0;
} warningPicture;

picture {
box { color = 255,255,255; height = 10; width = 10; };
   x = 0; y = 0;
} pic1;

begin_pcl;

# include libraries
include "stringfunctions.include.pcl";
include "serialfunctions.include.pcl";

int x;
int y;

# determine joystick center value
int midx = int(query_var("x"));
int midy = int(query_var("y"));

loop until false
begin
	# get x and y coordinates
	x = int(query_var("x")) - midx;
	y = int(query_var("y")) - midy;
	
	# move picture to the new coordinate
	pic1.set_part_x(1, x);
	pic1.set_part_y(1, y);
	pic1.present();
end;